#pragma once
#include <opencv2/opencv.hpp>
#include <vector>
using std::vector;
using cv::Mat;
using cv::Point2d;
using cv::KeyPoint;
using cv::Point;
class BlobDetector
{
public:
	using Params = cv::SimpleBlobDetector::Params;
	virtual ~BlobDetector() = default;
	//struct Params : public cv::SimpleBlobDetector::Params
	//{
	//	Params();
	//	/*float thresholdStep;
	//	float minThreshold;
	//	float maxThreshold;
	//	size_t minRepeatability;
	//	float minDistBetweenBlobs;
	//	bool filterByColor;
	//	uchar blobColor;
	//	bool filterByArea;
	//	float minArea, maxArea;
	//	bool filterByCircularity;
	//	float minCircularity, maxCircularity;
	//	bool filterByInertia;
	//	float minInertiaRatio, maxInertiaRatio;
	//	bool filterByConvexity;
	//	float minConvexity, maxConvexity;*/
	//};
	BlobDetector(const BlobDetector::Params &parameters);
	void detect(const Mat& image, CV_OUT vector<KeyPoint>& keypoints, CV_OUT vector<vector<Point>>& keycontours) const;
protected:
	struct Center
	{
		Point2d location;
		double radius;
		double confidence;
	};
	virtual void detectImpl(const Mat& image, vector<KeyPoint>& keypoints, vector<vector<Point>>& keycontours) const;
	virtual void findBlobs(const Mat &image, const Mat &binaryImage, vector<Center> &centers, vector<vector<Point>>& keycontours) const;
	Params params;
};

